package celular;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

import celular.cadastrar.FormCadastrarUsuario;
import celular.criar.FormCriar;
import celular.criar.FormCriarBlog;
import celular.pesquisar.FormPesquisar;
import celular.pesquisar.FormPesquisarBlog;

public class FormAdministracao extends Form implements CommandListener{
			
		private TextField textLogin, textSenha;
		private List mainMenu;

		private Command commandSair, commandLogar;
		private boolean cadastrado = false;
		private Main main;
		private Command commandAlterarConta;
		private Command commandDeletarConta;
		private Command commandCriarBlog;
		private Command commandAlterarBlog;
		private Command commandPesquisarBlog;
		private Command commandFazerLogoff;
		private Command commandPesquisarPost;
		

		public FormAdministracao(String titulo, Main main)
		{
			
			super(titulo);
			
			this.main = main;
		
			setCommandListener(this);   

			addCommand(this.commandAlterarConta = new Command("Alterar Conta", Command.OK, 0));	
			addCommand(this.commandDeletarConta = new Command("Deletar Conta", Command.OK, 1));
			addCommand(this.commandCriarBlog = new Command("Criar Blog", Command.OK, 2));
			addCommand(this.commandAlterarBlog = new Command("Alterar Blog", Command.OK, 3));
			addCommand(this.commandPesquisarBlog = new Command("Pesquisar Blog", Command.OK, 4));
			addCommand(this.commandPesquisarPost = new Command("Pesquisar Post", Command.OK, 5));
			addCommand(this.commandFazerLogoff = new Command("Fazer Logoff", Command.OK, 6));

			
			
			
			
		}
		
		public void commandAction(Command c, Displayable d)
		{
			if (c == this.commandAlterarConta)
				this.main.getTela().setCurrent(new FormCadastrarUsuario("Alterar Conta", this.main,this));
			
			else if (c == this.commandCriarBlog)
				this.main.getTela().setCurrent(new FormCriar("Criar Blog", this.main,"Descricao"));
			
			else if (c == this.commandAlterarBlog)
				this.main.getTela().setCurrent(new FormCriar("Alterar Blog", this.main, "Descricao"));		   
			
			else if (c == this.commandPesquisarBlog)
				this.main.getTela().setCurrent(new FormPesquisar("Pesquisar Blog", 
						this.main, "Blog", "Titulo"));
			
			else if (c == this.commandPesquisarPost)
				this.main.getTela().setCurrent(new FormPesquisar("Pesquisar Post",
						this.main, "Post", "Texto"));
			
			else if (c == this.commandFazerLogoff)
				this.main.setCurrentMain();
			
		}
		
		
		
	}


